package com.carrot.gateway.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * 登录类型
 */
@Getter
@AllArgsConstructor
public enum LoginTypeEnum {

    /** 类型 */
    PASSWD(1, "密码登录"),
    SMS_CAPTCHA(2, "短信验证码登录"),
    THIRD(3, "第三方登录"),

    ;
    private final Integer code;
    private final String desc;


    public static LoginTypeEnum getByCode(Integer code){
        return Stream.of(LoginTypeEnum.values())
                .filter(item -> item.getCode().equals(code)).findFirst()
                .orElse(null);
    }
}
